package hngc.com;

import java.util.Scanner;

public class Box17 {
    public static void main(String[] args) {
        int y = 0;
        int m = 0;
        int d = 0;
        int flag = 1;
        Scanner scanner = new Scanner(System.in);
        System.out.println("输入年：");
        while (scanner.hasNext()){
            try {
                y=scanner.nextInt();
                System.out.println("输入月：");
                m=scanner.nextInt();
                break;
            }catch (Exception e){
                System.out.println("必须为正整数");
            }
        }
                if(y>0){
            if (m==1||m==3||m==5||m==7||m==8||m==10||m==12){
                d=31;
            }else if(m==4||m==6||m==9||m==11){
                d=30;
            }else if(m==2){
                if(y%4==0&&y%100!=0||y%400==0){
                    d=29;
                }else {
                    d=28;
                }

            }else {
                flag=0;
            }

            if (flag == 0) {
                System.out.println("月份错误");
            } else {
                System.out.format("%d年%d月有%d天!\n", y, m, d);
            }
        }else {

            System.out.println("年份错误，必须为正整数");
        }
    }
}
